<template>
	<benben-popup
		v-model="isShow"
		:mask="true"
		:mask-close-able="false"
		mode='center'
		z-index="1080"
	>
		<view class="flex benben-flex-layout flex-wrap align-center">
			<view class='flex flex-direction flex-wrap align-center'>
				<view class='flex flex-direction align-center simplifiedPaper_fd1_0_c0'>
					<text class='simplifiedPaper_fd1_0_c0_c0'>修改对话名称</text>
					<view class='flex flex-wrap align-start simplifiedPaper_fd1_0_c0_c1'>
						<textarea
							type="text"
							:placeholder="placeholder"
							confirm-type="done"
							:maxlength="-1"
							style="color: #fff;height: 86%;word-break: break-all;"
							placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx"
							v-model.trim="title"
							:disabled="submitLoading"
						/>
					</view>
					<view class='flex flex-wrap align-center simplifiedPaper_fd1_0_c0_c2'>
						<view
							class='flex flex-wrap align-center justify-center simplifiedPaper_fd1_0_c0_c2_c0'
							@click.stop="isShow=false"
						>
							<text class='simplifiedPaper_fd1_0_c0_c2_c0_c0'>取消</text>
						</view>
						<button
							:loading="submitLoading"
							class='flex flex-wrap align-center justify-center simplifiedPaper_fd1_0_c0_c2_c1'
							@click.stop="submit"
						>
							<text class='simplifiedPaper_fd1_0_c0_c2_c0_c0'>确认修改</text>
						</button>
					</view>
				</view>
				<image
					class='simplifiedPaper_fd1_0_c1'
					mode="aspectFit"
					:src='STATIC_URL+"74.png"'
					@click.stop="isShow=false"
				></image>
			</view>
		</view>
	</benben-popup>
</template>

<script>
	/**
	 * @event {Function} open 打开弹窗显示
	 */
	export default {
		data() {
			return {
				isShow: false,
				placeholder: "",
				title: "",
				sessionId: "",
				submitLoading: false,
			}
		},
		methods: {
			open(title, id) {
				this.sessionId = id;
				this.title = title || '';
				this.placeholder = title || '';
				this.isShow = true;
			},
			async submit() {
				if (this.submitLoading) return;
				this.submitLoading = true;
				if (this.title) {
					await this.$post('65a749c392b98', { aid: this.sessionId, title: this.title });
					this.$emit('confirm', { id: this.sessionId, title: this.title });
					this.isShow = false;
				} else this.isShow = false;
				this.submitLoading = false;
			},
		}
	}
</script>

<style
	lang="scss"
	scoped
>
	@import './../digitalPersonUseMessage.scss';
</style>